package com.dadonas.utils;

import android.text.TextUtils;

public class ValidationException extends Exception {

	private static final long serialVersionUID = 5037808949381869937L;
	private StringBuffer messages;
	
	public ValidationException(){
		super();
	}
	
	public ValidationException(String message){
		super();
		addMessage(message);
	}
	
	public void addMessage(String message){
		if (messages == null){
			messages = new StringBuffer();
		}
		
		messages.append(message+"\n");
		
	}
	
	public boolean hasMessages(){
		return messages != null && !TextUtils.isEmpty(messages);
	}
	
	public StringBuffer getMessages(){
		return messages;
	}

	@Override
	public String getMessage() {
		if (messages != null){
			return messages.toString();
		} else{
			return "";
		}
	}

}
